package Homework;

import java.util.Arrays;

public class demo2 {
    public static void sort(int[] arr) {
        for (int i = 0; i < arr.length-1; i++) {
            if (arr[i]%2==0 &&arr[i+1]%2!=0) {
                int temp = arr[i];
                arr[i] = arr[i + 1];
                arr[i + 1] = temp;
            }
            }
        }

    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6};
        System.out.println("修改前的数组"+ Arrays.toString(arr));
        sort(arr);
        System.out.println("修改后的数组"+Arrays.toString(arr));
    }
}
